$(document).ready(function() {
   
	var textoDefault = $('#form_cadastro for').attr('title');
	
	var baseUrl = $("#baseUrl").text();

	 $(".deletar_pessoa").click(function(){
		 
		 if (!confirm("Deseja deletar mesmo?")) return false;
	    	jQuery.ajax({
	            type: "POST",
	            url: baseUrl + '/pessoa/deletar',
	            dataType: "json",
	            data: {
	                id: $(this).attr('rel')
	            } ,


	            beforeSend: function (XMLHttpRequest) {
	                
	            },

	            complete: function (XMLHttpRequest, textStatus) {},
	            //@todo verificar porque reload 
	            //esta chamando o reenviar. tipo f5
	            success: function(msg, textStatus){
	                alert('Deletado com sucesso');
	                window.location.reload();
	            }

	        });
	    });
	 
    $("#formListar").change(function(){

        if($("#formListar :input[name=tipoFiltro]:checked").val() == "Aniversario"){
            $("#formListar div")[8].style.display = 'block'
            $("#formListar div")[13].style.display = 'none'
            $("#formListar div")[17].style.display = 'none'
        }
        if($("#formListar :input[name=tipoFiltro]:checked").val() == "Bairro"){
            $("#formListar div")[13].style.display = 'block'
            $("#formListar div")[8].style.display = 'none'
            $("#formListar div")[17].style.display = 'none'
        }
        if($("#formListar :input[name=tipoFiltro]:checked").val() == "Rua"){
            $("#formListar div")[17].style.display = 'block'
            $("#formListar div")[8].style.display = 'none'
            $("#formListar div")[13].style.display = 'none'
        }

    });

});